<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use common\models\Category;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Documents');
$this->params['breadcrumbs'][] = $this->title;
?>
<hr/>
<div class="document-index">


    <p>
        <?= Html::a(Yii::t('app', '新增文章'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
//			['class' => \yii\grid\CheckboxColumn::className()],
            'id',
			[
				'header' => '<a href="javascript:void()">文章标题</a>',
				'content' => function ($model) {
					return $model->title;
				}
			],
			[
				'header' => '<a href="javascript:void()">所属分类</a>',
				'content' => function ($model) {
					$category = new Category();
					return $category->getPname($model->category_id);
				}
			],
             'view',
             'comment',
             'create_time:datetime',

			[
				'class' => 'yii\grid\ActionColumn',
				'header' => '<a href="javascript:void()">操作</a>',
				'template' => '{update} {delete}',
			],
        ],
    ]); ?>

</div>

<script>
	<?php $this->beginBlock('js_end') ?>

	$(function(){
		highlight_subnav("<?= Url::to(['article/index']) ?>");
	});

	<?php $this->endBlock() ?>
</script>

<?php $this->registerJs($this->blocks['js_end'], \yii\web\View::POS_END); ?>
